import request from '@/utils/request'
/**
 *  获取组织架构数据
 *  getDepartments
 *  GET
 */
export const getDepartments = () => {
  // 返回一个promise
  return request({
    url: '/company/department'
  })
}

/**
 *  根据ID删除部门
 *  根据id根据部门  接口是根据restful的规则设计的   删除 delete  新增 post  修改put 获取 get
 *  delDepartments
 *  DELETE
 */
export const delDepartments = id => {
  // 返回一个promise
  return request({
    url: `/company/department/${id}`,
    method: 'DELETE'
  })
}

/**
 *  新增组织架构数据
 *  addDepartments
 *  POST
 */
export const addDepartments = data => {
  // 返回一个promise
  return request({
    url: '/company/department',
    method: 'POST',
    data
  })
}

/**
 *  获取部门详情
 *  getDepartDetail
 *  GET
 */
export const getDepartDetail = id => {
  // 返回一个promise
  return request({
    url: `/company/department/${id}`
  })
}

/**
 *  编辑部门
 *  updateDepartments
 *  PUT
 */
export const updateDepartments = data => {
  // 返回一个promise
  return request({
    url: `/company/department/${data.id}`,
    method: 'PUT',
    data
  })
}
